package view.ext;

import javax.swing.*;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableColumn;
import java.awt.*;
import java.util.Vector;

public class CourseViewTable extends JTable {
    public CourseViewTable() {
        //super(mainViewTableModel);
        JTableHeader tableHeader = getTableHeader();
        tableHeader.setFont(new Font(null, Font.BOLD, 16));
        //设置表格体
        setFont(new Font(null, Font.PLAIN, 14));
        setForeground(Color.black);
        setGridColor(Color.BLACK);
        setRowHeight(30);
        //多行选择
        getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    }

    //设置渲染方式
    public void renderRuleCourse() {
        Vector<String> columns1 = CourseViewTableModel.getColumns();
        CourseViewCellRender render1 = new CourseViewCellRender();
        for (int i = 0; i < columns1.size(); i++) {
            TableColumn column1 = getColumn(columns1.get(i));
            column1.setCellRenderer(render1);
            if (i == 0) {
                column1.setPreferredWidth(50);
                column1.setMaxWidth(50);
                column1.setResizable(false);
            }
        }
    }
}
